package footprint.kwlee.app.db;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;

public class DetailItem implements java.io.Serializable{
	private int d_id;
	private int bigfootprint_id;
	private String detail_date;
	private String detail_time;
	private String detail_pic1_path;
	private String detail_pic2_path;
	private String detail_pic3_path;
	private String detail_memo;
	private String detail_addr;
	private String member_pwd;
	private String detail_kind;
	private String latitude;
	private String longitude;

	private BitmapDrawable photo1, photo2, photo3;
	private String date;
	private String height;
	private String weight;
	private String content;
	
	private Bitmap resize, bm;
	
	private BitmapFactory.Options options,options2,options3,options4;
	
	public DetailItem()
	{
		getoptions();
	}
	
	public void getoptions(){
	    options = new BitmapFactory.Options();
	    options.inSampleSize = 1;
	    options2 = new BitmapFactory.Options();
	    options2.inSampleSize =2;
	    options3 = new BitmapFactory.Options();
	    options3.inSampleSize = 4;
	    options4 = new BitmapFactory.Options();
	    options4.inSampleSize = 8;
	}
	
	public void setPhoto1(String image1)
	{
		detail_pic1_path = image1;
		if(image1.equals("no image"))
		{
			
		}
		else
		{
			image1(image1);
		}
	}
	
	public void setPhoto2(String image2)
	{
		detail_pic2_path = image2;
		if(image2.equals("no image"))
		{
			
		}
		else
		{
			image2(image2);
		}
	}
	
	public void setPhoto3(String image3)
	{
		detail_pic3_path = image3;
		if(image3.equals("no image"))
		{
			
		}
		else
		{
			image3(image3);
		}
	}
	
	public void image1(String image)
	{
		try{
			int getwidth = getBitmapOfWidth(image);
			if(getwidth <1200){ 
			   
				bm = BitmapFactory.decodeFile(image, options);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }else if(getwidth <2400){
			    bm = BitmapFactory.decodeFile(image, options2);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }else if(getwidth <4000){
			    bm = BitmapFactory.decodeFile(image, options4);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }else{
			    bm = BitmapFactory.decodeFile(image, options4);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }
		    bm.recycle();	
		}catch(OutOfMemoryError oe){
		}
		photo1 = new BitmapDrawable(resize);
	}
	
	public void image2(String image)
	{
		try{
			int getwidth = getBitmapOfWidth(image);
			if(getwidth <1200){ 
			   
				bm = BitmapFactory.decodeFile(image, options);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }else if(getwidth <2400){
			    bm = BitmapFactory.decodeFile(image, options2);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }else if(getwidth <4000){
			    bm = BitmapFactory.decodeFile(image, options4);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }else{
			    bm = BitmapFactory.decodeFile(image, options4);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }
		    bm.recycle();	
		}catch(OutOfMemoryError oe){
		}
		photo2 = new BitmapDrawable(resize);
	}
	
	public void image3(String image)
	{
		try{
			int getwidth = getBitmapOfWidth(image);
			if(getwidth <1200){ 
			   
				bm = BitmapFactory.decodeFile(image, options);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }else if(getwidth <2400){
			    bm = BitmapFactory.decodeFile(image, options2);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }else if(getwidth <4000){
			    bm = BitmapFactory.decodeFile(image, options4);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }else{
			    bm = BitmapFactory.decodeFile(image, options4);
			    resize = Bitmap.createScaledBitmap(bm, 700, 600, true);
		    }
		    bm.recycle();	
		}catch(OutOfMemoryError oe){
		}
		photo3 = new BitmapDrawable(resize);
	}
	
	public static int getBitmapOfWidth( String fileName ){
		try {
			BitmapFactory.Options options = new BitmapFactory.Options();
	        options.inJustDecodeBounds = true;
	        BitmapFactory.decodeFile(fileName, options);
	        return options.outWidth;
	    } catch(Exception e) {
	    	return 0;
	    }
	}
	
	public void setDate(String date)
	{
		this.date = date;
	}
	
	public void setHeight(String height)
	{
		this.height = height;
	}
	
	public void setWeight(String weight)
	{
		this.weight = weight;
	}
	
	public void setContent(String content)
	{
		this.content = content;
	}
	
	public BitmapDrawable getPhoto1()
	{
		return photo1;
	}
	
	public BitmapDrawable getPhoto2()
	{
		return photo2;
	}
	
	public BitmapDrawable getPhoto3()
	{
		return photo3;
	}
	
	public String getDate()
	{
		return date;
	}
	
	public String getHeight()
	{
		return height;
	}
	
	public String getWeight()
	{
		return weight;
	}
	
	public String getContent()
	{
		return content;
	}
	
	public int getD_id() {
		return d_id;
	}

	public void setD_id(int d_id) {
		this.d_id = d_id;
	}

	public int getBigfootprint_id() {
		return bigfootprint_id;
	}

	public void setBigfootprint_id(int bigfootprint_id) {
		this.bigfootprint_id = bigfootprint_id;
	}

	public String getDetail_date() {
		return detail_date;
	}

	public void setDetail_date(String detail_date) {
		this.detail_date = detail_date;
	}

	public String getDetail_time() {
		return detail_time;
	}

	public void setDetail_time(String detail_time) {
		this.detail_time = detail_time;
	}

	public String getDetail_pic1_path() {
		return detail_pic1_path;
	}

	public void setDetail_pic1_path(String detail_pic1_path) {
		this.detail_pic1_path = detail_pic1_path;
	}

	public String getDetail_pic2_path() {
		return detail_pic2_path;
	}

	public void setDetail_pic2_path(String detail_pic2_path) {
		this.detail_pic2_path = detail_pic2_path;
	}

	public String getDetail_pic3_path() {
		return detail_pic3_path;
	}

	public void setDetail_pic3_path(String detail_pic3_path) {
		this.detail_pic3_path = detail_pic3_path;
	}

	public String getDetail_memo() {
		return detail_memo;
	}

	public void setDetail_memo(String detail_memo) {
		this.detail_memo = detail_memo;
	}

	public String getDetail_addr() {
		return detail_addr;
	}

	public void setDetail_addr(String detail_addr) {
		this.detail_addr = detail_addr;
	}

	public String getMember_pwd() {
		return member_pwd;
	}

	public void setMember_pwd(String member_pwd) {
		this.member_pwd = member_pwd;
	}

	public Bitmap getResize() {
		return resize;
	}

	public void setResize(Bitmap resize) {
		this.resize = resize;
	}

	public Bitmap getBm() {
		return bm;
	}

	public void setBm(Bitmap bm) {
		this.bm = bm;
	}

	public BitmapFactory.Options getOptions() {
		return options;
	}

	public void setOptions(BitmapFactory.Options options) {
		this.options = options;
	}

	public BitmapFactory.Options getOptions2() {
		return options2;
	}

	public void setOptions2(BitmapFactory.Options options2) {
		this.options2 = options2;
	}

	public BitmapFactory.Options getOptions3() {
		return options3;
	}

	public void setOptions3(BitmapFactory.Options options3) {
		this.options3 = options3;
	}

	public BitmapFactory.Options getOptions4() {
		return options4;
	}

	public void setOptions4(BitmapFactory.Options options4) {
		this.options4 = options4;
	}

	public void setPhoto1(BitmapDrawable photo) {
		this.photo1 = photo;
	}
	
	public void setPhoto2(BitmapDrawable photo) {
		this.photo2 = photo;
	}
	
	public void setPhoto3(BitmapDrawable photo) {
		this.photo3 = photo;
	}

	public String getDetail_kind() {
		return detail_kind;
	}

	public void setDetail_kind(String detail_kind) {
		this.detail_kind = detail_kind;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}
	
}
